﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MCComDLL
{
    public class COMMessage
    {
        private byte _id;
        private byte _dlc;

        public byte id
        {
            set { this._id = value; }
            get { return this._id; }
        }
        public byte dlc
        {
            set { this._dlc = value; }
            get { return this._dlc; }
        }

        public byte[] data = new byte[80];

        public COMMessage()
        {
            id = 0;
            dlc = 0;
            foreach (byte i in data)
            {
                data[i] = 0;
            }
        }

        public byte getData(int index)
        {
            return data[index];
        }

        public void setData(byte data_in, int index)
        {
            data[index] = data_in;
        }

        public byte[] toByteArray()
        {
            byte[] ret = new byte[this.dlc + 4];
            
            ret[0] = 0xAA;
            ret[1] = 0x55;
            ret[2] = id;
            ret[3] = dlc;
            Array.Copy(data, 0, ret, 4, dlc);
            return ret;
        }

    }
}
